package com.itheima.app;

import com.itheima.bean.Dog;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

public class App1 {
    public static void main(String[] args) {
        // 上下文对象
        ApplicationContext ctx = new ClassPathXmlApplicationContext("applicationCOntext1.xml");
        // get bean 的多种方法
        System.out.println("get bean 的多种方法");
        Object cat = ctx.getBean("cat");
        System.out.println(cat);
        Dog dog = ctx.getBean(Dog.class);
        System.out.println(dog);

        System.out.println();
        // 获取所有的 bean
        System.out.println("获取所有的 bean");
        String[] names = ctx.getBeanDefinitionNames();
        for (String name : names) {
            System.out.println(name);
        }
    }
}
